<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>企业微信管理后台</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../css/reset.css">
    <link rel="stylesheet" href="../../css/fonts.css">
    <link rel="stylesheet" href="../../js/bootstrap/css/bootstrap.min.css">
    <!-- bootstrap表格 -->
    <link rel="stylesheet" href="../../js/bootstrap/js/bootstrap-table-master/bootstrap-table.min.css">
    <link rel="stylesheet" href="../../js/layui/css/layui.css">
    <link rel="stylesheet" href="../../css/main.css">
</head>

<body>
    <!--[if lt IE 7]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
    <div id="cus_logo">
        <div class="header">
            <div class="back">返回</div>
            <div class="type_select_wrapper">企业客户标签</div>
        </div>
        <div class="cus_logo_container">
            <div class="group_record">
                <div class="title">企业客户标签</div>
                <div class="desc">企业标签由企业统一配置，配置后，企业成员可以对客户打企业标签</div>
            </div>
            <!-- 2020-02-04 add Version2.0 -->
            <div class="logo_wrapper">
                <div class="normal_btn add_logogroup_btn">新增标签组</div>
                <div class="logo_container">
                    <div class="logo_group_section">标签组一</div>
                    <div class="logo_list">
                        <ul>
                            <li class="logo_item" data-id="0">一般</li>
                            <li class="logo_item" data-id="1">重要</li>
                            <li class="logo_item" data-id="2">核心</li>
                        </ul>
                    </div>
                    <div class="logolist_edit" data-groupid="0">编辑</div>
                </div>
                <div class="logo_container">
                    <div class="logo_group_section">标签组二</div>
                    <div class="logo_list">
                        <ul>
                            <li class="logo_item" data-id="3">一般</li>
                        </ul>
                    </div>
                    <div class="logolist_edit" data-groupid="1">编辑</div>
                </div>
            </div>
            <!-- 2020-02-04 add Version2.0 -->

            <!-- 客户列表 -->
            <div class="logo_cus_wrapper">
                <div class="logo_cus_tab">
                    <div class="tab_item active" data-index="0">有标签客户</div>
                    <div class="tab_item" data-index="1">无标签客户</div>
                </div>

                <div class="logo_table_wrapper">
                    <div class="have_logo_cus">
                        <form class="layui-form have_logo_form">
                            <div class="layui-form-item">
                                <span class="logo_title">标签筛选：</span>
                                <div class="layui-input-block">
                                    <input type="checkbox" lay-filter="logoSelect" name="logo" lay-skin="primary"
                                        title="一般" value="一般">
                                    <input type="checkbox" lay-filter="logoSelect" name="logo" lay-skin="primary"
                                        title="重要" value="重要">
                                    <input type="checkbox" lay-filter="logoSelect" name="logo" lay-skin="primary"
                                        title="核心" value="核心">
                                </div>
                            </div>
                            <!-- 2020-02-19 start -->
                            <div class="table_btn_wrapper">
                                <div class="normal_btn batch_setup h_batch_setup">批量修改</div>
                                <div class="import_table_cus">
                                    <div class="normal_btn import">导入客户</div>
                                    <input class="import_input"
                                        accept="application/vnd.ms-excel,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
                                        type="file" id="have_logo_import_inputFile" name="have_logo_import_inputFile">
                                </div>
                                <a href="javascript:;" class="normal_btn export_table_cus">导出客户</a>
                            </div>
                            <!-- 2020-02-19 end -->

                            <table class="layui-table h_table">
                                <thead>
                                    <tr>
                                        <th>
                                            <input type="checkbox" lay-filter="h_all_logo_select"
                                                name="h_all_logo_select" lay-skin="primary" value="全选">
                                        </th>
                                        <th>头像</th>
                                        <th>姓名</th>
                                        <th>标签</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>
                                            <input type="checkbox" lay-filter="h_logo_select" name="h_logo_select"
                                                lay-skin="primary" value="刘毅华">
                                        </td>
                                        <td>
                                            <img src="../../images/test.JPG" alt="">
                                        </td>
                                        <td>刘毅华</td>
                                        <td class="h_logos">一般,重要</td>
                                        <td>
                                            <span class="logo_edit" data-cus="刘毅华">修改</span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="checkbox" lay-filter="h_logo_select" name="h_logo_select"
                                                lay-skin="primary" value="赵虹蕊">
                                        </td>
                                        <td>
                                            <img src="../../images/test.JPG" alt="">
                                        </td>
                                        <td>赵虹蕊</td>
                                        <td class="h_logos">核心</td>
                                        <td>
                                            <span class="logo_edit" data-cus="赵虹蕊">修改</span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="checkbox" lay-filter="h_logo_select" name="h_logo_select"
                                                lay-skin="primary" value="吕海洋">
                                        </td>
                                        <td>
                                            <img src="../../images/test.JPG" alt="">
                                        </td>
                                        <td>吕海洋</td>
                                        <td class="h_logos">重要</td>
                                        <td>
                                            <span class="logo_edit" data-cus="吕海洋">修改</span>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <div class="paging_style" id="paging"></div>
                        </form>
                    </div>
                    <div class="no_logo_cus" style="display: none;">
                        <form class="layui-form no_logo_form">
                            <!-- 2020-02-19 start -->
                            <div class="table_btn_wrapper">
                                <div class="normal_btn batch_setup n_batch_setup">批量修改</div>
                                <a href="javascript:;" class="normal_btn no_cus_export_table">导出客户</a>
                            </div>
                            <!-- 2020-02-19 end -->

                            <table class="layui-table n_table">
                                <thead>
                                    <tr>
                                        <th>
                                            <input type="checkbox" lay-filter="n_all_logo_select"
                                                name="n_all_logo_select" lay-skin="primary" value="全选">
                                        </th>
                                        <th>头像</th>
                                        <th>姓名</th>
                                        <th>标签</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>
                                            <input type="checkbox" lay-filter="n_logo_select" name="n_logo_select"
                                                lay-skin="primary" value="刘毅华">
                                        </td>
                                        <td>
                                            <img src="../../images/test.JPG" alt="">
                                        </td>
                                        <td>刘毅华</td>
                                        <td class="n_logos">一般,重要</td>
                                        <td>
                                            <span class="logo_edit" data-cus="刘毅华">修改</span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="checkbox" lay-filter="n_logo_select" name="n_logo_select"
                                                lay-skin="primary" value="赵虹蕊">
                                        </td>
                                        <td>
                                            <img src="../../images/test.JPG" alt="">
                                        </td>
                                        <td>赵虹蕊</td>
                                        <td class="n_logos">核心</td>
                                        <td>
                                            <span class="logo_edit" data-cus="赵虹蕊">修改</span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="checkbox" lay-filter="n_logo_select" name="n_logo_select"
                                                lay-skin="primary" value="吕海洋">
                                        </td>
                                        <td>
                                            <img src="../../images/test.JPG" alt="">
                                        </td>
                                        <td>吕海洋</td>
                                        <td class="n_logos">重要</td>
                                        <td>
                                            <span class="logo_edit" data-cus="吕海洋">修改</span>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <div class="paging_style" id="n_paging"></div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 编辑标签模态框 -->
    <div class="modal fade" id="logo_edit_modal" tabindex="-1" role="dialog" aria-labelledby="logo_edit_modal_label">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="logo_edit_modal_label">编辑标签</h4>
                </div>
                <div class="modal-body">
                    <!-- 2020-02-04 add Version2.0 -->
                    <div class="msg_container">
                        <div class="logo_title">标签组名称</div>
                        <div class="logo_container">
                            <input class="layui-input" name="edit_logoGroup" type="text" placeholder="请输入标签组名称" value=""
                                data-groupid="">
                        </div>
                    </div>
                    <!-- 2020-02-04 add Version2.0 -->
                    <div class="msg_container">
                        <div class="logo_title">标签</div>
                        <div class="logo_container">
                            <ul id="logo_list"></ul>
                        </div>
                        <div class="add_logo_btn danger-bg">添加标签</div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-danger" id="submit_logoGroup_edit">确认</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>
    <!-- 编辑标签模态框 -->

    <!-- 新增标签模态框 -->
    <div class="modal fade" id="logo_add_modal" tabindex="-1" role="dialog" aria-labelledby="logo_add_modal_label">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="logo_add_modal_label">新增标签</h4>
                </div>
                <div class="modal-body">
                    <!-- 2020-02-04 add Version2.0 -->
                    <input name="logo_add_modal_groupid" type="hidden" value="">
                    <!-- 2020-02-04 add Version2.0 -->
                    <div class="msg_container">
                        <form class="layui-form">
                            <input type="text" name="add_logo_name" placeholder="请输入标签" autocomplete="off"
                                class="layui-input">
                        </form>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="submit_add_logo">确认</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>
    <!-- 新增标签模态框 -->

    <!-- 2020-02-04 add Version1.0 -->
    <!-- 新增标签组模态框 -->
    <div class="modal fade" id="logoGroup_add_modal" tabindex="-1" role="dialog"
        aria-labelledby="logoGroup_add_modal_label">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="logoGroup_add_modal_label">新增标签组</h4>
                </div>
                <div class="modal-body">
                    <!-- 2020-02-04 add Version2.0 -->
                    <div class="msg_container">
                        <div class="logo_title">标签组名称</div>
                        <div class="logo_container">
                            <input class="layui-input" name="add_logoGroup" type="text" placeholder="请输入标签组名称" value="">
                        </div>
                    </div>
                    <div class="msg_container">
                        <div class="logo_title">标签</div>
                        <div class="group_logo_items">
                            <div class="group_logo_item">
                                <input name="group_logo_item_value" class="layui-input group_logo_item" type="text"
                                    placeholder="请输入标签">
                            </div>
                        </div>
                        <div class="add_group_logo_item">新增标签</div>
                    </div>
                    <!-- 2020-02-04 add Version2.0 -->
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="submit_add_logoGroup">确认</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>
    <!-- 新增标签组模态框 -->
    <!-- 2020-02-04 add Version1.0 -->

    <!-- 批量修改标签、修改标签模态框 -->
    <div class="modal fade" id="cus_logo_edit_modal" tabindex="-1" role="dialog"
        aria-labelledby="cus_logo_edit_modal_label">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="cus_logo_edit_modal_label">标签修改</h4>
                </div>
                <div class="modal-body">
                    <div class="msg_container">
                        <form class="layui-form">
                            <div class="layui-form-item">
                                <span class="logo_title">标签：</span>
                                <div class="layui-input-block">
                                    <input type="checkbox" lay-filter="cus_logo_edit" name="cus_logo_edit"
                                        lay-skin="primary" title="一般" value="一般">
                                    <input type="checkbox" lay-filter="cus_logo_edit" name="cus_logo_edit"
                                        lay-skin="primary" title="重要" value="重要">
                                    <input type="checkbox" lay-filter="cus_logo_edit" name="cus_logo_edit"
                                        lay-skin="primary" title="核心" value="核心">
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" id="submit_cus_logo_edit">确认</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>
    <!-- 批量修改标签、修改标签模态框 -->

    <!-- 2020-02-19 start -->
    <!-- 加载动画 -->
    <div class="mask-bg">
        <div class="mask-loading">
            <div class="sk-spinner sk-spinner-cube-grid">
                <div class="iconfont icon-jiazai"></div>
            </div>
            <div class="tip">加载中</div>
        </div>
    </div>
    <!-- 2020-02-19 end -->

    <script src="../../js/jquery-3.3.1.min.js"></script>
    <script src="../../js/bootstrap/js/bootstrap.min.js"></script>
    <script src="../../js/layui/layui.js"></script>
    <!-- 树形结构 -->
    <script src="../../js/proTree.js"></script>
    <script>
        // 2020-02-20 start
        //获取url中的参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg); //匹配目标参数
            if (r != null) return unescape(r[2]);
            return null; //返回参数值
        }
        let nav_index = getUrlParam('nav_index') // 拿到点击进来的nav_index
        // 2020-02-20 end

        layui.use('layer', function () {
            var layer = layui.layer;

            // 2020-02-20 start
            // 返回父级页面
            $(".back").click(function() {
                parent.location.href = "enterprise-staffing.html?nav_index=" + nav_index
            })
            // 2020-02-20 end

            // tab切换
            $(".logo_cus_tab").on('click', '.tab_item', function () {
                $(this).addClass('active').siblings().removeClass('active')
                if ($(this).attr('data-index') == 0) {
                    $(".have_logo_cus").show()
                    $(".no_logo_cus").hide()
                } else {
                    $(".have_logo_cus").hide()
                    $(".no_logo_cus").show()
                }
            })
            // 2020-02-04 add Version2.0
            $(".logolist_edit").click(function () {
                let logoGroupName = $(this).siblings('.logo_group_section').text()
                let groupId = $(this).attr('data-groupid')
                // 取到当前标签组内的标签 并赋给编辑弹窗内的标签
                let logoList = []
                $(this).siblings('.logo_list').find('.logo_item').each(function () {
                    let data = {
                        id: $(this).attr('data-id'),
                        name: $(this).text()
                    }
                    logoList.push(data)
                })
                let logoHtml = ""
                for (let i = 0; i < logoList.length; i++) {
                    logoHtml += `<li class="logo_item"><span>${logoList[i].name}</span><i data-id="${logoList[i].id}" class="iconfont icon-shanchu"></i></li>`
                }
                $("#logo_list").html(logoHtml)
                $("input[name=edit_logoGroup]").attr('data-groupid', groupId)
                console.log('当前标签组内的标签', logoList)
                $("#logo_edit_modal").modal('show')
                $("input[name=edit_logoGroup]").val(logoGroupName)
            })
            // 2020-02-04 add Version2.0

            // 删除标签
            $("#logo_list").on('click', '.icon-shanchu', function () {
                let logoId = $(this).attr('data-id')
                layer.confirm('确认删除此标签吗？', {
                    btn: ['取消', '确认']
                }, function (index) {
                    layer.close(index)
                }, function () {
                    layer.msg('删除成功')
                })
            })
            // 2020-02-04 add Version2.0
            $(".add_logo_btn").click(function () {
                let groupid = $('input[name=edit_logoGroup]').attr('data-groupid')
                $("input[name=logo_add_modal_groupid]").val(groupid)
                $("#logo_add_modal").modal('show')
            })
            // 2020-02-04 add Version2.0

            // 新增标签
            $("#submit_add_logo").click(function () {
                let logoName = $("input[name=add_logo_name]").val()
                if (logoName == '') {
                    layer.msg('标签不能为空')
                    return false
                }
                console.log(logoName)
                $("#logo_add_modal").modal('hide')
            })

            layui.use('form', function () {
                var form = layui.form;
                let logoSelected = []
                form.on('checkbox(logoSelect)', function (data) {
                    if (data.elem.checked) {
                        logoSelected.push(data.value)
                    } else {
                        logoSelected.splice(data.value, 1)
                    }
                    console.log(logoSelected);
                });

                // 有标签客户 全选
                form.on('checkbox(h_all_logo_select)', function (data) {
                    if (data.elem.checked) {
                        $("input[name=h_logo_select]").prop('checked', true)
                        form.render('checkbox')
                    } else {
                        $("input[name=h_logo_select]").prop('checked', false)
                        form.render('checkbox')
                    }
                })

                // 无标签客户 全选
                form.on('checkbox(n_all_logo_select)', function (data) {
                    if (data.elem.checked) {
                        $("input[name=n_logo_select]").prop('checked', true)
                        form.render('checkbox')
                    } else {
                        $("input[name=n_logo_select]").prop('checked', false)
                        form.render('checkbox')
                    }
                })

                // 【有标签客户】有一个未选中全选取消选中
                form.on('checkbox(h_logo_select)', function (data) {
                    var item = $("input[name=h_logo_select]");
                    for (var i = 0; i < item.length; i++) {
                        if (item[i].checked == false) {
                            $("input[name=h_all_logo_select]").prop("checked", false);
                            form.render('checkbox');
                            break;
                        }
                    }
                    //如果都勾选了  勾上全选
                    var all = item.length;
                    for (var i = 0; i < item.length; i++) {
                        if (item[i].checked == true) {
                            all--;
                        }
                    }
                    if (all == 0) {
                        $("input[name=h_all_logo_select]").prop("checked", true);
                        form.render('checkbox');
                    }
                });

                // 【无标签客户】有一个未选中全选取消选中
                form.on('checkbox(n_logo_select)', function (data) {
                    var item = $("input[name=n_logo_select]");
                    for (var i = 0; i < item.length; i++) {
                        if (item[i].checked == false) {
                            $("input[name=n_all_logo_select]").prop("checked", false);
                            form.render('checkbox');
                            break;
                        }
                    }
                    //如果都勾选了  勾上全选
                    var all = item.length;
                    for (var i = 0; i < item.length; i++) {
                        if (item[i].checked == true) {
                            all--;
                        }
                    }
                    if (all == 0) {
                        $("input[name=n_all_logo_select]").prop("checked", true);
                        form.render('checkbox');
                    }
                });

                // 【有标签客户】批量修改
                var selectedCus = []
                $(".h_batch_setup").click(function () {
                    selectedCus = []
                    let item = $("input[name=h_logo_select]:checked")
                    console.log(item.length)
                    if (item.length == 0) {
                        layer.msg('未选中任何客户，无法进行批量修改')
                        return false
                    } else {
                        for (let i = 0; i < item.length; i++) {
                            selectedCus.push(item[i].value)
                        }
                        console.log(selectedCus)
                        $('input[name=cus_logo_edit]').prop('checked', false)
                        form.render('checkbox')
                        $("#cus_logo_edit_modal").modal('show')
                    }
                })

                // 【无标签客户】批量修改
                $(".n_batch_setup").click(function () {
                    selectedCus = []
                    let item = $("input[name=n_logo_select]:checked")
                    console.log(item.length)
                    if (item.length == 0) {
                        layer.msg('未选中任何客户，无法进行批量修改')
                        return false
                    } else {
                        for (let i = 0; i < item.length; i++) {
                            selectedCus.push(item[i].value)
                        }
                        console.log(selectedCus)
                        $('input[name=cus_logo_edit]').prop('checked', false)
                        form.render('checkbox')
                        $("#cus_logo_edit_modal").modal('show')
                    }
                })


                // 批量修改确认
                $("#submit_cus_logo_edit").click(function () {
                    let item = $("input[name=cus_logo_edit]:checked")
                    let selectedLogo = []
                    for (let i = 0; i < item.length; i++) {
                        selectedLogo.push(item[i].value)
                    }
                    console.log('已选择的客户', selectedCus, '已选择的标签', selectedLogo)
                    $("#cus_logo_edit_modal").modal('hide')
                })

                // 【有标签客户】点击行内修改
                $(".h_table").on('click', '.logo_edit', function () {
                    selectedCus = []
                    // 默认所有选项为空
                    $("input[name=cus_logo_edit]").each(function () {
                        $(this).prop('checked', false)
                        form.render('checkbox')
                    })
                    selectedCus.push($(this).attr('data-cus'))
                    let logos = $(this).parent().siblings('.h_logos').text().split(',')
                    for (let i = 0; i < logos.length; i++) {
                        $("input[name=cus_logo_edit]").each(function () {
                            if (logos[i] == $(this).val()) {
                                $(this).prop('checked', true)
                            }
                            form.render('checkbox')
                        })
                    }
                    $("#cus_logo_edit_modal").modal('show')
                })

                // 【无标签客户】点击行内修改
                $(".n_table").on('click', '.logo_edit', function () {
                    selectedCus = []
                    // 默认所有选项为空
                    $("input[name=cus_logo_edit]").each(function () {
                        $(this).prop('checked', false)
                        form.render('checkbox')
                    })
                    selectedCus.push($(this).attr('data-cus'))
                    let logos = $(this).parent().siblings('.n_logos').text().split(',')
                    for (let i = 0; i < logos.length; i++) {
                        $("input[name=cus_logo_edit]").each(function () {
                            if (logos[i] == $(this).val()) {
                                $(this).prop('checked', true)
                            }
                            form.render('checkbox')
                        })
                    }
                    $("#cus_logo_edit_modal").modal('show')
                })

                // 2020-02-04 add Version2.0
                // 新增标签组
                $(".add_logogroup_btn").click(function () {
                    $("input[name=add_logoGroup]").val('')
                    let html = '<div class="group_logo_item"><input name="group_logo_item_value" class="layui-input group_logo_item" type="text" placeholder="请输入标签"></div>'
                    $(".group_logo_items").html(html)
                    $("#logoGroup_add_modal").modal('show')
                })
                // 新增标签组确认
                $("#submit_add_logoGroup").click(function () {
                    let logoGroupName = $("input[name=add_logoGroup]").val() //标签组名称

                    if (logoGroupName == '') {
                        layer.msg('标签组名称不能为空')
                        return false
                    }
                    let logos = []
                    $("input[name=group_logo_item_value]").each(function () {
                        if ($(this).val() == '') {
                            layer.msg('标签名称不能为空')
                            return false
                        }
                        logos.push($(this).val())
                    })
                    console.log(logoGroupName, logos)
                    // $("#logoGroup_add_modal").modal('hide')
                })

                // 编辑标签模态框确认
                // 2020-02-04 add Version2.0
                $("#submit_logoGroup_edit").click(function () {
                    let logoGroupName = $("input[name=edit_logoGroup]").val() // 标签组名称
                    let groupid = $('input[name=edit_logoGroup]').attr('data-groupid') // 标签组id
                    console.log(logoGroupName, groupid)
                    if (logoGroupName == '') {
                        layer.msg('标签组名称不能为空')
                        return false
                    }

                    $("#logo_edit_modal").modal('hide')
                })
                // 2020-02-04 add Version2.0

                // 标签组内新增标签
                $(".add_group_logo_item").click(function () {
                    let html = '<div class="group_logo_item"><input name="group_logo_item_value" class="layui-input group_logo_item" type="text" placeholder="请输入标签"><span class="delete_logo">删除</span></div>'
                    $(".group_logo_items").append(html)
                    // 标签组内删除标签
                    $(".delete_logo").click(function () {
                        $(this).parent().remove()
                    })
                })
                // 标签组内删除标签
                $(".delete_logo").click(function () {
                    $(this).parent().remove()
                })
                // 2020-02-04 add Version2.0


                // 2020-02-19 start
                // 有标签客户 导入客户
                $("#have_logo_import_inputFile").on('change', function (e) {
                    var fileObj = e.currentTarget.files[0]; // js 获取文件对象
                    console.log('fileObj', fileObj)
                    if (typeof (fileObj) == "undefined" || fileObj.size <= 0) {
                        alert("请选择文件");
                        return;
                    }
                    var formdata = new FormData();
                    formdata.append('fileType_file', fileObj);
                    formdata.append('fileType', "import_cus");
                    // 执行ajax请求
                    // $.ajax({
                    //     url: "",
                    //     type: 'POST',
                    //     dataType: 'json',
                    //     processData: false,
                    //     contentType: false,
                    //     cache: false,
                    //     data: formdata
                    // })
                    //     .done(function (data) {
                    //         // 请求完毕do something
                    //     })
                    //     .fail(function () {
                    //         console.log("error");
                    //     })
                    $(".mask-bg").show()
                    // 模拟导入成功效果
                    setTimeout(() => {
                        $(".mask-bg").hide()
                        layer.msg('导入成功')

                    }, 2000)

                });
                // 2020-02-19 end
            })

        })

        // 表格分页
        layui.use('laypage', function () {
            var laypage = layui.laypage;
            // 【有标签客户】
            laypage.render({
                elem: 'paging',
                limit: 5,
                theme: '#E51C23',
                count: 20, //数据总数，从服务端得到
                jump: function (obj, first) {
                    //obj包含了当前分页的所有参数，比如：
                    console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                    console.log(obj.limit); //得到每页显示的条数
                    //首次不执行
                    if (!first) {
                        //do something
                    }
                }
            })

            // 【无标签客户】
            laypage.render({
                elem: 'n_paging',
                limit: 5,
                theme: '#E51C23',
                count: 20, //数据总数，从服务端得到
                jump: function (obj, first) {
                    //obj包含了当前分页的所有参数，比如：
                    console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                    console.log(obj.limit); //得到每页显示的条数
                    //首次不执行
                    if (!first) {
                        //do something
                    }
                }
            })
        });
    </script>
</body>

</html>